/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package zombieville.GUI;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import zombieville.auxiliares.ApoioImagens;
import zombieville.engine.Cenario;

/**
 *
 * @author Alisson
 */
public class TelaMenu extends JPanel {

    private Image imagem;
    private TelaControles telaControles;
    ControleGUI controleGui;

    public TelaMenu(ControleGUI controleGui) {

        this.controleGui = controleGui;
        
        imagem = ApoioImagens.carregaImagem("/Imagens/menu.png");

        telaControles = new TelaControles(this);

        addMouseListener(new ControleMouse());
        
        this.requestFocus();
    }

    public class ControleMouse extends MouseAdapter {

        private int x;
        private int y;

        @Override
        public void mouseClicked(MouseEvent e) {
            this.x = e.getX();
            this.y = e.getY();

            if ((x > 320 && x < 505) && (y > 105 && y < 145)) {
                controleGui.novaPartida();
            }
            
            if ((x > 320 && x < 505) && (y > 217 && y < 256)) {
                setVisible(false);
                controleGui.getJanelaPrincipal().getContentPane().add(telaControles);
                telaControles.setVisible(true);
            }
            
            if ((x > 320 && x < 505) && (y > 354 && y < 393)) {
                System.exit(0);
            }
        }
    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);

        g.drawImage(imagem, 0, 0, controleGui.getJanelaPrincipal().getWidth(), controleGui.getJanelaPrincipal().getHeight(), this);
    }
}